package com._21cn.cms.resource.entity;

import com._21cn.framework.utils.DateUtil;

import java.io.File;
import java.io.Serializable;
import java.util.Date;

public class Picture implements Serializable {
	private static final long serialVersionUID = -1L;	
	
	private Integer id;
	private Integer siteId = 0;
	private String title;
	private String fileName;
	private String extName;
	private String host;
	private String path;
	private String hashcode;
	private Integer width;
	private Integer height;
	private Integer fileSize;
	private Integer status;
	private Date createTime = new Date();
	private Integer createUserId;
	private Date modifyTime = new Date();
	private Integer modifyUserId;
	private String originalUrl;
	private String memo;

    private transient File tempFile;    //临时文件

    public File getTempFile() {
        return tempFile;
    }
    public void setTempFile(File tempFile) {
        this.tempFile = tempFile;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return this.id;
    }
    public void setSiteId(Integer siteId) {
        this.siteId = siteId;
    }

    public Integer getSiteId() {
        return this.siteId;
    }
    public void setTitle(String title) {
        this.title = title;
    }

    public String getTitle() {
        return this.title;
    }
    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getFileName() {
        return this.fileName;
    }
    public void setExtName(String extName) {
        this.extName = extName;
    }

    public String getExtName() {
        return this.extName;
    }
    public void setHost(String host) {
        this.host = host;
    }

    public String getHost() {
        return this.host;
    }
    public void setPath(String path) {
        this.path = path;
    }

    public String getPath() {
        return this.path;
    }
    public void setHashcode(String hashcode) {
        this.hashcode = hashcode;
    }

    public String getHashcode() {
        return this.hashcode;
    }
    public void setWidth(Integer width) {
        this.width = width;
    }

    public Integer getWidth() {
        return this.width;
    }
    public void setHeight(Integer height) {
        this.height = height;
    }

    public Integer getHeight() {
        return this.height;
    }
    public void setFileSize(Integer fileSize) {
        this.fileSize = fileSize;
    }

    public Integer getFileSize() {
        return this.fileSize;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getStatus() {
        return this.status;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getCreateTime() {
        return this.createTime;
    }
    public void setCreateUserId(Integer createUserId) {
        this.createUserId = createUserId;
    }

    public Integer getCreateUserId() {
        return this.createUserId;
    }
    public void setModifyTime(Date modifyTime) {
        this.modifyTime = modifyTime;
    }

    public Date getModifyTime() {
        return this.modifyTime;  
    }  
    public void setModifyUserId(Integer modifyUserId) {  
        this.modifyUserId = modifyUserId;  
    }        
	
    public Integer getModifyUserId() {  
        return this.modifyUserId;  
    }  
    public void setOriginalUrl(String originalUrl) {  
        this.originalUrl = originalUrl;  
    }        
	
    public String getOriginalUrl() {  
        return this.originalUrl;  
    }  
    public void setMemo(String memo) {  
        this.memo = memo;  
    }        
	
    public String getMemo() {  
        return this.memo;  
    }

    /**
     * 拼凑图片原图的URL
     *
     * @return
     */
    public String getUrl() {
        return getUrl( "album", "o" );
    }

    public String getMidUrl() {
        return getUrl( "album", "m" );
    }

    public String getThumbUrl() {
        return getUrl( "album", "s" );
    }

    public String getUrl( String channelCode, String sizeFlag ) {
        if( getHost() == null || channelCode == null || getCreateTime() == null || getHashcode() == null )
            return null;
        return "http://" + getHost() + "/photos/" + channelCode + "/" + DateUtil.formatDate(getCreateTime(), "yyyyMMdd") + "/" + sizeFlag + "/" + getHashcode() + "." + getExtName();
    }
}